<template>
    <!-- mine/pages/einvoiceDetails/einvoiceDetails.wxml -->
    <view class="einvoiceDetails">
        <!-- 抬头 -->
        <view class="title">
            <view class="title-left">
                <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/finish.png" class="img"></image>
                <span v-if="invoiceDetail.invoiceStatus == 'INVOICE_APPLYING'" class="applying">审核中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'INVOICE_CHECK'" class="applying">审核中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'IN_INVOICE'" class="applying">审核中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'INVOICE_FAIL'" class="applying">开票失败</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'CANCEL_INVOICE'" class="applying">已退票</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'INVOICE_FINISH'" class="applying">已开票</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'INVOICE_REJECT'" class="applying">已退票</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'REDED'" class="applying">已退票</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'NO_INVOICE'" class="applying">未开票</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'RED_APPLYING'" class="applying">审核中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'RED_CHECK'" class="applying">审核中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'IN_RED'" class="applying">审核中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'RED_FAIL'" class="applying">冲红失败</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'IN_THE_VOID'" class="applying">作废中</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'VOIDED'" class="applying">已作废</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'RED_REJECT'" class="applying">驳回冲红</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'TO_PUSH'" class="applying">重新推送</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'VOID_APPLYING'" class="applying">申请作废</span>
                <span v-else-if="invoiceDetail.invoiceStatus == 'RED_INVOICE'" class="applying">审核中</span>
            </view>
            <view class="title-right">
                {{ invoiceDetail.applicationTime }}
            </view>
        </view>
        <!-- 详情 -->
        <view class="details">
            <view class="details-title">发票详情</view>
            <view class="details-list">
                <view class="details-list-in">
                    <view>发票类型</view>
                    <!-- <view>{{ invoiceDetail.invoiceTypeName ? invoiceDetail.invoiceTypeName : '暂无' }}</view> -->
					<view v-if="invoiceDetail.invoiceType == 1">电子普通发票</view>
					<view v-if="invoiceDetail.invoiceType == 2">纸质专用发票</view>
					<view v-if="invoiceDetail.invoiceType == 3">电子专用发票</view>
					
                </view>
                <view class="details-list-in">
                    <view>发票抬头</view>
                    <view>{{ invoiceDetail.invoiceRise }}</view>
                </view>
                <view class="details-list-in">
                    <view>税号</view>
                    <view>{{ invoiceDetail.dutyParagraph }}</view>
                </view>
                <view class="details-list-in">
                    <view>发票内容</view>
                    <view>{{ invoiceDetail.invoiceItemEnum }}</view>
                </view>
                <view class="details-list-in">
                    <view>发票金额</view>
                    <view class="actualBalance">{{ invoiceDetail.actualBalance }}元</view>
                </view>
                <view class="details-list-in">
                    <view>申请时间</view>
                    <view>{{ invoiceDetail.applicationTime }}</view>
                </view>
            </view>
        </view>

        <!-- 收件方式 -->
        <view class="details">
            <view class="details-title">收件方式</view>
            <view class="details-list">
                <view class="details-list-in">
                    <view>电子邮件</view>
                    <view class="emailNo">{{ invoiceDetail.email }}</view>
                </view>
            </view>
        </view>

        <!-- 总计 -->
        <view class="sum" @tap="invoice" :data-bill="invoiceDetail.billIds">
            <view class="sum-in">
                <view class="sum-left">
                    <span>1</span>
                    张发票，含
                    <span>{{ invoiceDetail.billIds.length }}</span>
                    个充电订单
                </view>
                <view class="sum-right">
                    <span>查看</span>
                    <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/turn.png"></image>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
'use strict';

// exports.__esModule = true; // mine/pages/einvoiceDetails/einvoiceDetails.ts

var https_1 = require('./../../../api/https.js');
export default {
    data() {
        return {
            id: 0,
            invoiceDetail: {
                invoiceStatus: '',
                applicationTime: '',
                invoiceTypeName: false,
                invoiceRise: '',
                dutyParagraph: '',
                invoiceItemEnum: '',
                actualBalance: '',
                email: '',
                billIds: ''
            }
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        if (options.id) {
            this.id=options.id
        }
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.queryInvoiceDetailById();
    },
    methods: {
        //查询发票详情
        queryInvoiceDetailById: function () {
            var that = this;
            https_1.queryInvoiceDetailById(this.id).then(function (res) {
                if (res.code == 0) {
                    var data = res.data;
                    data.actualBalance = (data.actualBalance / 100).toFixed(2);
                    that.invoiceDetail=data
                }
            });
        },

        invoice: function (e) {
            var billIds = e.currentTarget.dataset.bill; // console.log("打印",billIds,JSON.stringify(billIds))
            // const pages = getCurrentPages()
            //             const prevPage = pages[pages.length - 2]
            //             prevPage.show=false,
            //              prevPage.tabIndex=2
            //             })
            //             wx.navigateBack()

            uni.navigateTo({
                url: '../einvoiceChargingOrder/einvoiceChargingOrder?billIds=' + JSON.stringify(billIds)
            });
        }
    }
};
</script>
<style lang="less">
@import url('./einvoiceDetails.less');
</style>
